import { ApiProperty } from '@nestjs/swagger';
import { QueryPageDto } from './query.page.dto';

export class PageDto<T> {
  constructor(query: QueryPageDto<any>, record?: T[], total?: number) {
    this.page = query.page;
    this.size = query.size;

    if (record != undefined) {
      this.record = record;
    }
    if (total != undefined) {
      this.total = total;
    }
  }

  @ApiProperty({ description: '总数' })
  total: number;
  @ApiProperty({ description: '页码', default: 1 })
  page: number;
  @ApiProperty({ description: '页数', default: 10 })
  size: number;
  @ApiProperty({ description: '数据' })
  record: T[];
}
